package com.example.administrator.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

/**
 * Created by Administrator on 2016/3/18 0018.
 */
public class BaseActivity extends Activity{
    //起动Activity时调用此方向   一般用来做初始化工作
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);


    }

    //即将可见时调用此方向
    @Override
    protected void onStart()
    {

        super.onStart();
    }

    //用户可以看见并且交互的时候
    @Override
    protected void onResume()
    {
        super.onResume();
    }

    //当这个窗口没有被完全覆盖时   一般用来保存一些临时数据
    @Override
    protected void onPause()
    {
        super.onPause();
    }

    //当这个窗口完全不可见
    @Override
    protected void onStop()
    {
        super.onStop();
    }

    //当这个窗口要销毁时   用来做清理性工作
    @Override
    protected void onDestroy()
    {
        super.onDestroy();
    }

    @Override
    protected void onRestart()
    {
        super.onRestart();
    }


    //窗口的跳转
    /*****窗口的跳转******/
    protected void startActivity(Class<?> cls)
    {
      /*  Intent intent = new Intent(this, cls);
        startActivity(intent);*/
        startActivity(cls, null);
    }

    protected void startActivity(Class<?> cls,Bundle bdl)
    {
        Intent intent = new Intent(this, cls);
        if(bdl!=null)
        {
            intent.putExtras(bdl);
        }
        startActivity(intent);
    }
    //设置全屏
    protected void setFullScreen()
    {
        requestWindowFeature(Window.FEATURE_NO_TITLE);  //无title
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);  //全屏
    }
    protected void initTitleBar(int leftImgId,String title,int rightImgId,View.OnClickListener onClickListener){

        TitleBar titleBar = (TitleBar) findViewById(R.id.title_bar);
        titleBar.initActionBar(leftImgId,title,rightImgId,onClickListener);
    }
}
